package com.imedway.ihe.client;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.lcm.SubmitObjectsRequest;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.RegistryObjectListType;
import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rs.RegistryResponseType;
import org.openehealth.ipf.commons.ihe.xds.iti42.Iti42PortType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2024/7/3
 */
@Slf4j
@RestController
@RequestMapping("iti42")
public class Iti42PortTypeClient {

    @PostMapping
    public void iti42() throws MalformedURLException {
        URL wsdlUrl = new URL("http://localhost:8080/services/iti42?wsdl");
        QName serviceName = new QName("http://service.ihe.imedway.com/", "Iti42PortTypeImplService");
        Service service = Service.create(wsdlUrl, serviceName);
        Iti42PortType myWebService = service.getPort(Iti42PortType.class);
        SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest();
        RegistryObjectListType registryObjectList = new RegistryObjectListType();


        submitObjectsRequest.setRegistryObjectList(registryObjectList);
        RegistryResponseType registryResponseType = myWebService.documentRegistryRegisterDocumentSetB(submitObjectsRequest);
        log.info(registryResponseType.getRequestId());
    }

}